<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>业务审核记录查询页面</title>
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/easyui_my.css">
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${ctx}/css/css.css" />
<script type="text/javascript" src="${ctx}/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="${ctx}/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx }/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/js/common.js"></script>
<script type="text/javascript" src="${ctx}/js/placehold.js"></script>
</head>
<body class="easyui-layout" options="border:false">
<div data-options="region:'north',height:62,border:false" style="padding-left:10px;padding-right: 10px;padding-top: 5px;">
  <div class="xinxichaxunkuangz1">
    <div class="dashujtiaojianxuanxiangkuan">
      <div class="dashujtiaojianxuanxiangkuan_lie" style="58px;">
          <div class="tiaojian_key">开始时间：</div>
          <div class="tiaojian_values">
            <ul class="tiaojian_values_limian" style="width:1030px;">
              <li>
                <input id="startTime" type="text" name="startTime" class="easyui-datetimebox shurukuangkais"/>
              </li>
              <li><span class="buchongdbiaotdsw">结束时间：</span>
                <input id="endTime" type="text" name="endTime" class="easyui-datetimebox shurukuangkais"/>
              </li>
               
               <li><!-- <span class="buchongdbiaotdsw">状态：</span> -->
                <input id="zt" name="zt" class="easyui-combobox shurukuangkais " 
                      data-options="valueField: 'id',
                       prompt:'请选择状态',
                      textField: 'text', 
                      panelHeight:'auto',
					  editable:false,
                      data:[
                            {id:'0',text:'待审核'},
                            {id:'1',text:'审核通过'},
                            {id:'2',text:'审核不通过'}]"/>
              </li>
              <li><!-- <span class="buchongdbiaotdsw">权限类型：</span> -->
                <input id="permissionType" name="permissionType" value="" class="easyui-combobox inputclass" 
                      data-options="valueField: 'id',
                      prompt:'请选择权限类型',
                      textField: 'text', 
                      editable:false,
                      panelHeight:100,
                      data:[{id:'01',text:'打印权限'},
                            {id:'02',text:'下载权限'},
                            {id:'03',text:'删除权限'}]"/>
              </li>
               <li>
					<input id="lsh"  type="text" class="shurukuangkais" placeholder="请输入流水号" value=""  />
	             </li>
              </ul>
          </div>
        </div>
      </div>
      <div class="chaxunchongzhianniu">
        <a href="javascript:void(0);" name='batchAudit' zt='1' class="congzhim" style="display:none;">审核通过</a>
        <a href="javascript:void(0);" name='batchAudit' zt='2' class="congzhim" style="display:none;">审核不通过</a>
        <a href="javascript:queryDataGrid()" class="sousuocx">查询</a>
      </div>
    </div>
 </div>
<div data-options="region:'center',border:false" style="padding-left:10px;padding-right: 10px">
  <div class="easyui-layout xinxichaxunkuangz2" data-options="fit:true,border:false">
    <div class="tupianqiehuantop" data-options="region:'north',border:false" style="height: 37px">
      <span class="chaxunjieguosd">搜索结果</span>
    </div>
    <div id="tableDiv" data-options="region:'center',border:false" style="overflow-y: auto;">
      <table id="TableData" data-options="cls:'biaogeycangds',fit:true"></table>
    </div>
    <div data-options="region:'south',border:false" style="height:32px">
      <div class="easyui-panel">
        <div class="easyui-pagination" id="pp"></div>
      </div>
     </div>
  </div>
</div>
<script type="text/javascript">

$(function(){
	debugger;
    //设置日期初始值
    $("#startTime").datetimebox("setValue",getDatex(7));
    $("#endTime").datetimebox("setValue",getDatex1(-1));
    initTable(1,20);
    var $batchAudit=$('a[name=batchAudit]');
    //权限类型选择切换
    $('#permissionType,#zt').combobox({
        onChange: function (val,o) {
        	//选了具体某一种状态，立马重新查询一次（方便按钮控制）
        	queryDataGrid();
        	$batchAudit.show();
        	var zt=$('#zt').combobox('getValue');
        	var permissionType=$('#permissionType').combobox('getValue');
        	if(permissionType!='' && zt=='0'){
        		//权限类型不是全部且状态选了待审核才展示按钮，否则展示按钮没有意义
        		//展示批量审核通过、批量审核不通过按钮
                $batchAudit.show();
        	}else{
        		//隐藏批量审核通过、审核不通过按钮
                $batchAudit.hide();
        	}
        }
    });
    
  //批量审核操作
    $batchAudit.unbind('click').bind('click',function(){
    	debugger;
    	var $this=$(this);
    	var zt=$this.attr('zt');//状态
        var message=$this.text();
    	var selRows =$('#TableData').datagrid('getChecked');
    	var length=selRows.length;
    	if(length==0){
    		alert('请选中要审核的数据');
    		return false;
    	}else{
    		var applyNo='';//保存选中的apply,已逗号形式保存
    		$.each(selRows,function(i,data){
    			if(i==0){
    				applyNo=data.applyNo;
    			}else{
    				applyNo=applyNo+','+data.applyNo;
    			}
    		});
    		if(confirm('确认执行'+message+'操作?')){
                $.ajax({
                    type:'post',
                    url:'${ctx}/audit/auditApply.htm',
                    data:{
                       applyNo:applyNo,
                       zt:zt
                    },
                    success:function(data){
                        debugger;
                        if(data=='01'){
                            alert('审核成功');
                            queryDataGrid();//重新加载页面
                        }
                      
                    }
               });
            }else{
                return false;
            }
    	}
    });
});

//数据表
function initTable(pageNumber,pageSize){
	debugger;
    var param={
        pageSize:pageSize,
        page:pageNumber,
        startTime:$("#startTime").combobox('getValue'),
        endTime:$("#endTime").combobox('getValue'),
        operatorType:'1'//方法入口    审核
    }
    var column=[[
    	{field:'',checkbox:true,align:'center',fixed:true,split:true},
    	{field:'lsh',title:'流水号',width:'120',fixed:true,align:'center',split:true},
        {field:'hphm',title:'号牌号码',width:'100',fixed:true,align:'center',split:true},
        {field:'ywlx',title:'业务类型',width:'100',fixed:true,align:'center',split:true},
        {field:'applicant',title:'申请人',width:'100',fixed:true,align:'center',split:true},
        {field:'strApplyDate',title:'申请时间',width:'150',fixed:true,align:'center',split:true},
        {field:'applicantBmmc',title:'申请人所在部门',width:'260',fixed:true,align:'center',split:true},
        {field:'strPermission',title:'权限类型',width:'100',fixed:true,align:'center',split:true},
        {field:'strZt',title:'状态',width:'120',fixed:true,align:'center',split:true},
        {field:'cz',title:'操作',width:'300',align:'center',fixed:true,split:true,formatter:function(value,row,index){
            if(row.zt=='0'){
                return "<a href='javascript:void(0)' name='audit' zt='1' permissionType='"+row.permissionType+"' applyNo='"+row.applyNo+"' class=\"chense\" >审核通过</a>&nbsp;&nbsp;&nbsp;&nbsp;"+
                "<a href='javascript:void(0)' zt='2' permissionType='"+row.permissionType+"' applyNo='"+row.applyNo+"' name='audit' class=\"chense\">审核不通过</a>&nbsp;&nbsp;&nbsp;&nbsp;"+
                "<a href=\"javascript:CheckInfo('"+row.lsh+"','"+row.xh+"','"+index+"','"+row.applyNo+"')\" class=\"chense2\" >详情</a>";
            }else{
                return "<a href=\"javascript:CheckInfo('"+row.lsh+"','"+row.xh+"','"+index+"','"+row.applyNo+"')\" class=\"chense2\" >详情</a>";
            }
            
        }}
      ]];
      loadTable('TableData','${ctx}/audit/queryAuditByPage.htm',param,column);
}

function CheckInfo(lsh,xh,_index,applyNo){
    debugger;
    //var param=getParam(xh,_index,'xh');
    var param=getParamLsh(lsh,_index,'lsh');
    var startTime = $("#startTime").combobox('getValue');
    var endTime = $("#endTime").combobox('getValue');
    param+="&startTime="+startTime+"&endTime="+endTime+"&url=yxsh/jdcViewFlag"+"&applyNo="+applyNo;
    parent.addTab("业务审核详情","${ctx}/yxxxgl/findYxsqxzByxhFirstIn.htm"+param);
}

function loadSuccess(){
    debugger;
    //审核事件(单个审核)
    $('a[name=audit]').unbind('click').bind('click',function(){
        var $this=$(this);
        var applyNo=$this.attr('applyNo');//申请编号
        var zt=$this.attr('zt');//状态
        var message=$this.text();
        if(confirm('确认执行'+message+'操作?')){
            $.ajax({
                type:'post',
                url:'${ctx}/audit/auditApply.htm',
                data:{
                   applyNo:applyNo,
                   zt:zt
                },
                success:function(data){
                    debugger;
                    if(data=='01'){
                        alert('审核成功');
                        queryDataGrid();//重新加载页面
                    }
                  
                }
           });
        }else{
            return false;
        }
    });
}


/* //此处点击事件不要了
function CheckInfo(xh){
    
}  */

//根据界面中的样件，过滤查询机动车基本信息列表
function queryDataGrid(){
	debugger;
    var startTime = $("#startTime").combobox('getValue');//开始时间
    var endTime = $("#endTime").combobox('getValue');//结束时间
    var permissionType=$('#permissionType').combobox('getValue');//权限类型
    var zt=$('#zt').combobox('getValue');//状态
    var lsh=$('#lsh').val();
    $("#TableData").datagrid("load",{
          startTime:startTime,
          endTime:endTime,
          permissionType:permissionType,
          zt:zt,
          operatorType:'1',//方法入口    审核
          lsh:lsh
          
     });
}
    //清空申请页面信息
    function clearInfo(){
    	 $('#hphmmc').text('');
         $('#hpzlmc').text('');
         $('#clpp1').text('');
         $('#csysmc').text('');
         $('#syr').text('');
         $('#fdjh').text('');
         $('#clsbdh').text('');
         $('#wkccmc').text('');
    }
</script>
</body>
</html>
